##Comparison to ANES 2016

library(foreign)

##set working directory
setwd("C:/Users/lmh735/Dropbox (Political Science)/Partisanship and leadership-Trump/2021 POBE Submission/R&R/Replication Files")

##load data
data.anes<- read.dta("anes_timeseries_2016_Stata12.dta")
dim(data.anes)

################################################
##           Prepare Variables                ##
################################################
##Demographics
summary(data.anes$V161158x) ##Party ID
data.anes$pid<- ifelse(data.anes$V161158x==-9 | data.anes$V161158x==-8, NA, data.anes$V161158x)
summary(data.anes$pid)

##Democrats and Republicans (leaners as partisans)
data.anes$dem<- ifelse(data.anes$pid<=3, 1, 0)
data.anes$rep<- ifelse(data.anes$pid>=5, 1, 0)

##Feeling thermometers  
##Trump feeling thermometer
summary(data.anes$V161087)
data.anes$trump.ft<- ifelse(data.anes$V161087 >=0, data.anes$V161087, NA)
summary(data.anes$trump.ft)

##Democratic Party feeling thermometer
summary(data.anes$V161095)
data.anes$dem.ft<- ifelse(data.anes$V161095 >=0, data.anes$V161095, NA)

##Republican Party feeling thermometer
summary(data.anes$V161096)
data.anes$rep.ft<- ifelse(data.anes$V161096 >=0, data.anes$V161096, NA)


##################################################################
##################################################################
##Assess FT views of Republicans here versus in our MTurk Sample
data.anes.rep<- subset(data.anes, data.anes$rep==1) ##includes learners

##view of Republicans
##FT of Trump
summary(data.anes.rep$trump.ft) 
sd(data.anes.rep$trump.ft, na.rm=TRUE)

##GOP FT
summary(data.anes.rep$rep.ft) 
sd(data.anes.rep$rep.ft, na.rm=TRUE)
